
layui.use(['layer', 'form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;
    admin.iframeAuto();


    form.on('submit(btnSubmit)', function (data) {
        var path_ = "/sam/project/add.json";
        if(data.field.id!=''){
            path_ = "/sam/project/edit.json";
        }
        var ajax = new $ax(Sam.ctxPath+path_, function (data) {
            Sam.success("保存成功！");
            admin.putTempData('formOk', true);
            admin.closeThisDialog();
        }, function (data) {
            Sam.error("保存失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
    });


   // upload.render({
   //   elem: '#uploadProjectImg' //绑定元素
   //   ,auto: true
   //   ,accept:'images'
   //   ,size: 4096 
   //   ,exts:'jpg|png|gif|bmp|jpeg'
   //   ,multiple: false
   //   ,url: Sam.ctxPath+'/sam/project/uploadfile'
   //   ,done: function(res){
   //    //上传完毕回调
   //   }
   //   ,error: function(){
   //    //请求异常回调
   //   }
   //  });


});